import unittest
from python接口测试.FIC_项目代号.tools_第三方工具包.bulid_data import bulid_data_json
from parameterized import parameterized
import requests
from python接口测试.FIC_项目代号.api_测试接口.LaoHuangLi import LaoHuangLi


class testLaoHuangLi02(unittest.TestCase):

    def setUp(self) -> None:
        self.LaoHuangLi = LaoHuangLi()
        self.session = requests.Session()

    def tearDown(self) -> None:
        if self.session:
            self.session.close()

    # json文件参数化
    @parameterized.expand(bulid_data_json())
    def testLaoHuangLi02(self, key, date, reason, error_code):
        response = self.LaoHuangLi.getLaoHuangLi(self.session, key, date)
        print(response.json())
        print(key,date,reason,error_code)
        self.assertEqual(200, response.status_code)
        self.assertEqual(reason, response.json().get("reason"))
        print(response.json().get("error_code"))
        self.assertEqual(error_code, response.json().get("error_code"))



